package com.ticket.system.mapper;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.ticket.system.domain.YanchuMovieCard;
import com.ticket.system.domain.vo.BatchExportVO;
import com.ticket.system.domain.vo.CardExportVO;
import org.apache.ibatis.annotations.Param;

/**
 * 观演卡数据Mapper接口
 * 
 * @author ruoyi
 * @date 2023-12-12
 */
public interface YanchuMovieCardMapper 
{
    /**
     * 查询观演卡数据
     * 
     * @param id 观演卡数据主键
     * @return 观演卡数据
     */
    public YanchuMovieCard selectYanchuMovieCardById(Long id);

    public YanchuMovieCard selectCardByCardNum(String cardNo);

    /**
     * 查询观演卡数据列表
     * 
     * @param yanchuMovieCard 观演卡数据
     * @return 观演卡数据集合
     */
    public List<YanchuMovieCard> selectYanchuMovieCardList(YanchuMovieCard yanchuMovieCard);

    /**
     * 新增观演卡数据
     * 
     * @param yanchuMovieCard 观演卡数据
     * @return 结果
     */
    public int insertYanchuMovieCard(YanchuMovieCard yanchuMovieCard);

    /**
     * 修改观演卡数据
     * 
     * @param yanchuMovieCard 观演卡数据
     * @return 结果
     */
    public int updateYanchuMovieCard(YanchuMovieCard yanchuMovieCard);

    /**
     * 删除观演卡数据
     * 
     * @param id 观演卡数据主键
     * @return 结果
     */
    public int deleteYanchuMovieCardById(Long id);

    /**
     * 批量删除观演卡数据
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteYanchuMovieCardByIds(Long[] ids);

    public int consume(@Param("id")Long id,@Param("userId")Long userId, @Param("amount")BigDecimal amount);

    /**
     * 批量新增观演卡数据
     *
     * @param cards
     * @return
     */
    int insertYanchuMovieCards(@Param("cards") List<YanchuMovieCard> cards);

    /**
     * 批次id修改有效时间
     *
     * @param batchId
     * @param time
     */
    void updateValidTimeByBatchId(@Param("batchId") Long batchId,@Param("time") Date time);

    /**
     * 批量设置有效时间
     *
     * @param cardIds
     */
    void updateValidTimeByCardIds(@Param("cardIds") List<Long> cardIds,
                                  @Param("time") Date time);

    /**
     * 批次id激活卡
     *
     * @param batchIds
     * @param activeId
     * @param activeName
     * @param date
     */
    void updateActiveByBatchId(@Param("batchIds") List<Long> batchIds,
                               @Param("activeId") Long activeId,
                               @Param("activeName") String activeName,
                               @Param("date") Date date);

    /**
     * pc获取卡列表
     *
     * @param cardNum
     * @param keyName
     * @param amount
     * @return
     */
    List<YanchuMovieCard> selectYanchuMovieCardByList(@Param("batchId") Long batchId,
                                                      @Param("cardNum") String cardNum,
                                                      @Param("amount") String amount,
                                                      @Param("keyName") String keyName,
                                                      @Param("status") Integer status);

    List<CardExportVO> selectCardNumByBatchId(@Param("batchId") Long batchId);

    BatchExportVO selectCardsByCardIds(@Param("carIds") List<Long> carIds);

    Integer getStorageAndBatch(Long userId);

    int updateBindMovieCard(@Param("cardNum") String cardNum,
                            @Param("userId") Long userId,
                            @Param("userName") String userName,
                            @Param("phonenumber") String phonenumber);

    void updateValidTimeByBatchIds(@Param("batchIds") List<Long> batchIds,
                                   @Param("time") Date time);

    /**
     * 退费
     * @param amount
     * @return
     */
    public int refund(@Param("cardNum")String cardNum, @Param("amount") BigDecimal amount,@Param("userId")Long userId);

    List<YanchuMovieCard> mobileCardList(@Param("userId") Long userId,@Param("type") Integer type);

    boolean checkValidTime(String cardNum);

}
